//
//  HXNewFeatherViewController.m
//  爱鲜蜂
//
//  Created by 建国 on 16/5/26.
//  Copyright © 2016年 建国. All rights reserved.
//
#import "HXTabBarController.h"
#import "HXNewFeatherViewController.h"

@interface HXNewFeatherViewController ()

@property (nonatomic,weak) UIScrollView *scrollNew ;

@property (nonatomic,weak) UIButton *button ;


@end

@implementation HXNewFeatherViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNewFeatherView];
    [self setupLoginButton] ;
}
//添加新特征界面
-(void)setupNewFeatherView{
    UIScrollView *newFeatherView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
//  scrollView的基本设置
    newFeatherView.pagingEnabled = YES ;
    newFeatherView.showsHorizontalScrollIndicator = NO ;
    newFeatherView.contentSize = CGSizeMake(4 * SCREEN_WIDTH, 0);
    newFeatherView.bounces = NO;
    self.scrollNew = newFeatherView ;
    [self addImageView];
    [self.view addSubview:newFeatherView];
    
}
-(void)addImageView{
    for (int i = 0; i < 4;  i++) {
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH * i, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        imageView.backgroundColor = HXRandomColor ;
        [self.scrollNew addSubview:imageView ];
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"guide_35_%d",i+1]];
    }
}

-(void)setupLoginButton{
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:[UIImage imageNamed:@"icon_next"] forState:(UIControlStateNormal)];
    [button addTarget:self action:@selector(jumpToMain) forControlEvents:(UIControlEventTouchUpInside)];
    [button sizeToFit];
    button.center = CGPointMake(SCREEN_WIDTH * 3.5 , SCREEN_HEIGHT * 0.9);
    [self.scrollNew addSubview:button];
}

-(void)jumpToMain{
    
    HXTabBarController *vc = [[HXTabBarController alloc]init];
    
    // 切换窗口的根控制器进行跳转
    [UIApplication sharedApplication].keyWindow.rootViewController = vc;
    
    CATransition *anim = [CATransition animation];
    anim.type = @"rippleEffect";
    anim.duration = 1;
    [[UIApplication sharedApplication].keyWindow.layer addAnimation:anim forKey:nil];
}


@end
